Revert r44257 "Use boolean searching with '?' char"
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2008 23:06:44 +0000 (23:06 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2008 23:06:44 +0000 (23:06 +0000)
Let's avoid making up our own syntax that nobody will know or think to try...
Lucene, Google, Yahoo!, and Windows Live search all understand "red OR lion" but see nothing special in "?red ?lion". If we're going to add it, let's make the OR thing work. :)

includes/SearchEngine.php
includes/SearchMySQL.php

index 6aa726c..66e8d9b 100644 (file)
@@ -150,7 +150,7 @@ class SearchEngine {
        }
 
        public static function legalSearchChars() {
-               return "A-Za-z_'0-9\\x80-\\xFF\\-\\?";
+               return "A-Za-z_'0-9\\x80-\\xFF\\-";
        }
 
        /**
index 6f2b338..f9b71c8 100644 (file)
@@ -43,18 +43,12 @@ class SearchMySQL extends SearchEngine {
 
                # FIXME: This doesn't handle parenthetical expressions.
                $m = array();
-               if( preg_match_all( '/([-+<>?~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', 
-                       $filteredText, $m, PREG_SET_ORDER ) )
-               {
+               if( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/',
+                         $filteredText, $m, PREG_SET_ORDER ) ) {
                        foreach( $m as $terms ) {
                                if( $searchon !== '' ) $searchon .= ' ';
-                               if( $this->strictMatching ) {
-                                       // '' means AND while ? means OR to the user
-                                       if( $terms[1] == '' ) {
-                                               $terms[1] = '+';
-                                       } else if( $terms[1] == '?' ) {
-                                               $terms[1] = '';
-                                       }
+                               if( $this->strictMatching && ($terms[1] == '') ) {
+                                       $terms[1] = '+';
                                }
                                $searchon .= $terms[1] . $wgContLang->stripForSearch( $terms[2] );
                                if( !empty( $terms[3] ) ) {